﻿using System.Collections;
using System.Collections.Generic;

using Dict.DataModel;
namespace Dict.Blo
{
    public class DictStrengthenMasterBlo
    {
        private static int[] maxLevels = new int[5];
        public static TableStrengthenMaster GetMeetMasterData(int type,int minEquipLev)
        {
            int equipStrenthMasterLev = 0;
            TableStrengthenMaster equipStrenthMasterLevData = null;
            List<Dict.DataModel.TableStrengthenMaster> masterData = Dict.DictDataManager.Instance.tableStrengthenMasterDao.GetByOneIndex(type);
            foreach (var data in masterData)
            {
                if (data.strengthenLevel >= equipStrenthMasterLev && minEquipLev >= data.strengthenLevel)
                {
                    equipStrenthMasterLevData = data;
                    equipStrenthMasterLev = data.level;
                }
            }
            return equipStrenthMasterLevData;
        }

        public static TableStrengthenMaster GetMasterData(int type, int masterLev)
        {
            List<Dict.DataModel.TableStrengthenMaster> masterData = Dict.DictDataManager.Instance.tableStrengthenMasterDao.GetByOneIndex(type);
            for(int i = 0; i < masterData.Count;++i)
            {
                if(masterData[i].level == masterLev && masterData[i].type == type)
                {
                    return masterData[i];
                }
            }
            return null;
        }

        public static int GetMaxLevel(int type)
        {
            int ind = type - 1;
            if(maxLevels[ind] > 0)
            {
                return maxLevels[ind];
            }
            List<Dict.DataModel.TableStrengthenMaster> masterData = Dict.DictDataManager.Instance.tableStrengthenMasterDao.GetByOneIndex(type);
            foreach (var data in masterData)
            {
                if(data.level > maxLevels[ind])
                {
                    maxLevels[ind] = data.level;
                }
            }
            return maxLevels[ind];
        }

    }
}
